package main

import (
	"log"
	"io"

	"golang.org/x/net/context"
	"google.golang.org/grpc"

	pb "helloworld/proto"
)

const Address string = ":8000"

var grpcClient pb.StreamServerClient

func listValue() {
	req := pb.SimpleRequest {
		Data: "stream server grpc",
	}
	stream , err := grpcClient.ListValue(context.Background(),&req)
	if err != nil {
		log.Fatalf("call listStr err: %v",err)
	}
	for {
		res, err := stream.Recv()
		if err == io.EOF {
			 break
		}
		if err != nil {
			log.Fatalf("ListStr get stream err: %v",err)
		}
		log.Println(res.StreamValue)
	}
}

func main() {
	conn, err := grpc.Dial(Address,grpc.WithInsecure())
	if err != nil {
		log.Fatal("net.Connect err: %v",err)
	}
	defer conn.Close()

	grpcClient = pb.NewStreamServerClient(conn)
	//route()
	listValue()
}

